<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="classes/conndb.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
       <meta name="viewport" content="width=device-width, initial-scale=1">
       <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" type="text/css" rel="stylesheet">
   </head>
   <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<body>
<div class="container">
  <div class="row">
	<%
		request.setCharacterEncoding("UTF-8");
		String message_id = request.getParameter("message_id") == null ? "" : request.getParameter("message_id");
		
	    String messager_name= "";
	    String messager_sex= "";
	    String messager_phone= "";
	    String messager_email= "";
	    String messager_address= "";
	    String submit_time= "";
	    String title ="";
	    String content = "";
	    String status = "";
	    String is_public = "";
	    String answer_content= "";
	    String answer_time ="";

	%>
	<%
     PreparedStatement ps= null;
     Connection con =null;
     ResultSet rs=null,rs2;

	 try {
			con = getConnection();
			String sql = "select t1.*,t2.content as answer_content,t2.operate_time as answer_time from cms_public_comment t1 left join cms_reply_comment t2 on t1.message_id = t2.message_id where t1.message_id=?";
	    	ps=con.prepareStatement(sql);
			ps.setObject(1, message_id);
	    	rs=ps.executeQuery();
	    	
	    	while (rs.next()) {
	    		messager_name= rs.getString("messager_name")== null ? "" : rs.getString("messager_name");
	    		messager_sex= rs.getString("messager_sex")== null ? "" : rs.getString("messager_sex").replace("1", "男").replace("0", "女");
	    		messager_phone= rs.getString("messager_phone")== null ? "" : rs.getString("messager_phone");
	    		messager_email= rs.getString("messager_email")== null ? "" : rs.getString("messager_email");
	    		submit_time= rs.getString("operate_time")== null ? "" : rs.getString("operate_time");
	    		title= rs.getString("title")== null ? "" : rs.getString("title");
	    		content= rs.getString("content")== null ? "" : rs.getString("content");
	    		status= rs.getString("status")== null ? "" : rs.getString("status").replace("1", "未办理").replace("2", "已回复").replace("3", "已完成");
	    		is_public= rs.getString("is_public")== null ? "" : rs.getString("is_public").replace("1", "是").replace("0", "否");
	    		answer_content= rs.getString("answer_content")== null ? "" : rs.getString("answer_content");
	    		answer_time= rs.getTimestamp("answer_time") == null ? "" : rs.getTimestamp("answer_time").toString().substring(0,rs.getTimestamp("answer_time").toString().lastIndexOf(".0"));

	    	}
	    }catch(Exception e){
			e.printStackTrace();
		}finally{
			closeConn(con,ps,rs);
		}
	%>
		<table class="table table-responsive" width="100%" border="0" cellspacing="0" cellpadding="0">
			<tbody>
				<tr>
					<th style="width:100px;">填写人：</th>
					<td><div class="col-xs-4"><%=messager_name %></div></td>
				</tr>
				<tr>
					<th>性    别：</th>
					<td><div class="col-xs-4"><%=messager_sex %></div></td>
				</tr>
				<tr>
					<th>电    话：</th>
					<td><div class="col-xs-4"><%=messager_phone %></div></td>
				</tr>
				<tr>
					<th>联系地址：</th>
					<td><div class="col-xs-4"><%=messager_address %></div></td>
				</tr>
				<tr>
					<th>Email地址：</th>
					<td><div class="col-xs-4"><%=messager_email %></div></td>
				</tr>
				<tr>
					<th>填写时间：</th>
					<td><div class="col-xs-4"><%=submit_time %></div></td>
				</tr>
				<tr>
					<th>标	题：</th>
					<td><div class="col-xs-4"><%=title %></div></td>
				</tr>
				<tr>
					<th>留言内容：</th>
					<td><div class="col-xs-4"><%=content %></div></td>
				</tr>
				
				<tr>
					<th>状态：</th>
					<td><div class="col-xs-4"><%=status %></div></td>
				</tr>
				<tr>
					<th>是否公开：</th>
					<td><div class="col-xs-4"><%=is_public %></div></td>
				</tr>
				<%if(!status.equals("未办理")) {%>
					<tr>
						<th>回复内容：</th>
						<td><div class="col-xs-4"><%=answer_content %></div></td>
					</tr>
					<tr>
						<th>回复时间：</th>
						<td><div class="col-xs-4"><%=answer_time %></div></td>
					</tr>
				<%}%>
			</tbody>
		</table>
</body>
</html>
